package org.nf.trading.service.app.product.impl;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nf.trading.dao.ProductTypeDetailMapper;
import org.nf.trading.entity.ProductTypeDetail;
import org.nf.trading.exception.app.product.ProductDataException;
import org.nf.trading.service.app.product.ProductTypeDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
@Transactional
public class ProductTypeDetailServiceImpl implements ProductTypeDetailService {
    private final ProductTypeDetailMapper productTypeDetailMapper;
    /**
     * 通过商品类型id查询全部商品类型详情
     * @param productTypeId
     * @return
     */
    @Override
    public List<ProductTypeDetail> getAllByProductTypeDetailsByTypeId(Integer productTypeId) {
        if (productTypeId == null){
            log.error("productTypeId为NULL");
            throw new ProductDataException(500,"productTypeId为NULL");
        }
        return productTypeDetailMapper.getAllByProductTypeDetailsByTypeId(productTypeId);
    }
}
